package org.csu.onlineedubackend.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.csu.onlineedubackend.entity.Chapter;

import java.util.List;

@Mapper
public interface ChapterMapper extends BaseMapper<Chapter> {

    //教师端使用
    @Select("SELECT * FROM chapter WHERE course_id = #{courseId} ORDER BY sort_order")
    List<Chapter> findByCourseId(Integer courseId);


    /**
     * 根据课程ID查询章节
     * @param courseId 课程ID
     * @return 章节列表
     */
    @Select("SELECT * FROM chapter WHERE course_id = #{courseId} ORDER BY sort_order ASC")
    List<Chapter> selectByCourseId(Integer courseId);
}
